# DemoConfig.cmake

message(STATUS "Looking for Demo components: ${Demo_FIND_COMPONENTS}")

# 检查是否请求了特定的组件
if(NOT Demo_FIND_COMPONENTS)
  set(Demo_FIND_COMPONENTS SubA SubB)
endif()


# 查找和设置 SubA 组件
if("SubA" IN_LIST Demo_FIND_COMPONENTS)
  if(DEMO_SUBA_LIBRARY)
    add_library(Demo::SubA SHARED IMPORTED)
    message(STATUS "Found Demo::SubA: ${DEMO_SUBA_LIBRARY}")
    set_target_properties(Demo::SubA PROPERTIES
      INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/../../include"
      IMPORTED_LOCATION "${DEMO_SUBA_LIBRARY}"
    )
    list(APPEND DEMO_FOUND_COMPONENTS SubA)
  else()
    set(Demo_SubA_FOUND FALSE)
  endif()
endif()

# 查找和设置 SubB 组件
if("SubB" IN_LIST Demo_FIND_COMPONENTS)
  if(DEMO_SUBB_LIBRARY)
    message(STATUS "Found Demo::SubB: ${DEMO_SUBB_LIBRARY}")
    add_library(Demo::SubB SHARED IMPORTED)
    set_target_properties(Demo::SubB PROPERTIES
      INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/../../include"
      IMPORTED_LOCATION "${DEMO_SUBB_LIBRARY}"
    )
    list(APPEND DEMO_FOUND_COMPONENTS SubB)
  else()
    set(Demo_SubB_FOUND FALSE)
  endif()
endif()

# 设置找到的组件
if(DEMO_FOUND_COMPONENTS)
  set(Demo_FOUND TRUE)
  foreach(component IN LISTS DEMO_FOUND_COMPONENTS)
    set(Demo_${component}_FOUND TRUE)
  endforeach()
else()
  set(Demo_FOUND FALSE)
endif()